import { exportUrl } from "@/api/report/mesProcessExceptionDetails";
import { getLineCodeListNew } from "@/api/order/mesProdOrder";
import { exportExcel } from "@/utils/judge";
import { getWareList } from "@/api/order/mesProdOrder.js";
import { getTeamCodeList } from "@/api/employee/mesUserExtend";
import { getDict } from "@/api/common";
// 列表头按钮配置
export const operateList = [
  {
    name: $i18n.t("common.export"),
    type: "primary",
    icon: "el-icon-download",
    handleName: "export", //点击时返回的标识
    url: exportUrl,
    //auth: "auth:operlog:export", //权限字段
  },
  // {
  //   name: "删除",
  //   type: "danger",
  //   icon: "el-icon-delete",
  //   handleName: "deleteBatch", //点击时返回的标识
  //   isMultiple: true, // isSingle 表示必须选择一项//isMultiple: true, // 表示必须多选
  // },
  // {
  //   name: "导入",
  //   type: "primary",
  //   icon: "el-icon-circle-plus-outline",
  //   handleName: "import", //点击时返回的标识
  // },
];
// 行末按钮配置
export const rowConfig = [];
// 搜索条件配置
export const searchConfig = {
  data() {
    return {
      searchConfig: {
        inline: true,
        formDesc: {
          defectiveStatus: {
            layout: 4,
            label: $i18n.t("mesProcessExceptionDetails.state"),
            type: "select",
            prop: {
              value: "value",
              text: "description",
            },
            options: async (data) => {
              const list = await getDict("defective_status");
              return list.data.result;
            },
          },
          date1: {
            layout:9,
            label:$i18n.t("common.createTime"),
            type: "datetimerange",
            attrs: {
              valueFormat: "yyyy-MM-dd HH:mm:ss",
              searchArrKey: ["beginDate", "endDate"],
            },
          },
          workshopCode: {
            type: "select",
            label: $i18n.t("mesProcessExceptionDetails.workshop"),
            prop: {
              value: "modelingCode",
              text: "modelingName",
            },
            options: async (data) => {
              const params = {
                modelingCode: this.$store.getters.factoryCode,
                level: 4,
                modelingType: "0",
              };
              const list = await getLineCodeListNew(params);
              return list.data.result;
            },
          },
          lineCode: {
            labelWidth: "90px",
            // layout: 7,
            label: $i18n.t("mesProdOrderPlanPassRatio.lineName"),
            type: "select",
            prop: {
              value: "modelingCode",
              text: "modelingName",
            },
            optionsLinkageFields: ["workshopCode"],
            options: async (data) => {
              if (data && data.workshopCode) {
                const params = {
                  modelingCode: data.workshopCode,
                  level: 5,
                };
                const list = await getLineCodeListNew(params);
                return list.data.result;
              } else {
                return [];
              }
            },
          },
          workTeamCode: {
            type: "select",
            label: $i18n.t("common.team"),
            optionsLinkageFields: ["lineCode"],
            isReloadOptions: true,
            attrs: {
              filterable: true,
            },
            prop: {
              value: "teamCode",
              text: "teamName",
            },
            options: async (data) => {
              // const list = await getTeamCodeList();
              // return list.data.result;
              if (data.lineCode) {
                const list = await getTeamCodeList({ lineCode: data.lineCode });
                return list.data.result;
              } else {
                return [];
              }
            },
          },
          productProcessCode: {
            type: "input",
            label: $i18n.t("common.processCode"),
          },
          productProcessName: {
            type: "input",
            label: $i18n.t("common.processName"),
          },
          prodCode: {
            type: "input",
            label:$i18n.t("mesProcessExceptionDetails.prodCode")// "产品编码",
          },
          prodName: {
            type: "input",
            label: $i18n.t("mesProcessExceptionDetails.prodName"),
          },
          orderCode: {
            type: "input",
            label:$i18n.t("mesProcessExceptionDetails.orderCode")// "工单编码",
          },
          equipmentName: {
            type: "input",
            label: $i18n.t("mesProcessExceptionDetails.equipmentName")
          },
          planCode: {
            type: "input",
            label: $i18n.t("mesProcessExceptionDetails.planCode")
          },
        },
      },
    };
  },
};
